fix: Cypress hangs when wrapping an object containing circular references #32917
+317
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional details
When
cy.wrap()is called with objects containing circular references, the logging code instringifyActualcauses infinite recursion because it doesn't track visited objects. This can lead to stack overflow errors - which cause the Cypress App to completely hang.I'm not sure if this is an issue with other command logs, but this addresses the issue with logging in general, so it would resolve situations there as well.
Steps to test
yarn cypress:openHow has the user experience changed?
Before
!!!! Complete Cypress App hang when running the test
After
PR Tasks
cypress-documentation?type definitions?Note
Track visited objects to safely stringify circular structures, preventing
cy.wrap()hangs and updating tests and changelog accordingly.packages/driver/src/cypress/utils.tsto detect circular references using aWeakSetinstringifyActual()/stringifyActualObj()and return[Circular],Array[N], orObject{N}safely.cy.wrap()inpackages/driver/cypress/e2e/commands/misc.cy.js(objects, arrays, nested/multiple refs; ensure logs include[Circular]and chaining works).packages/driver/cypress/e2e/cypress/utils.cy.jsto assert safe stringification of circular objects/arrays and adjust expectations for small/large arrays and object key counts.cy.wrap()freezing on circular references incli/CHANGELOG.md.Written by Cursor Bugbot for commit f84e3f4. This will update automatically on new commits. Configure here.